﻿namespace WinForms
{
    using System;
    using System.Management;

    public class GetMachineInfo
    {
        public static string GetCpuInfo()
        {
            string str = "";
            ManagementObjectCollection instances = new ManagementClass("Win32_Processor").GetInstances();
            foreach (ManagementObject obj2 in instances)
            {
                str = obj2.Properties["ProcessorId"].Value.ToString();
            }
            return str.ToString();
        }

        public static string GetHDid()
        {
            string str = "";
            ManagementObjectCollection instances = new ManagementClass("Win32_DiskDrive").GetInstances();
            foreach (ManagementObject obj2 in instances)
            {
                str = (string) obj2.Properties["Model"].Value;
            }
            return str.ToString();
        }

        public static string GetMoAddress()
        {
            string str = "";
            ManagementObjectCollection instances = new ManagementClass("Win32_NetworkAdapterConfiguration").GetInstances();
            foreach (ManagementObject obj2 in instances)
            {
                if ((bool) obj2["IPEnabled"])
                {
                    str = obj2["MacAddress"].ToString();
                }
                obj2.Dispose();
            }
            return str.ToString();
        }

        public static string GetTotalPhysicalMemory()
        {
            try
            {
                string str = "";
                ManagementObjectCollection instances = new ManagementClass("Win32_ComputerSystem").GetInstances();
                foreach (ManagementObject obj2 in instances)
                {
                    str = obj2["TotalPhysicalMemory"].ToString();
                }
                instances = null;
                return str;
            }
            catch
            {
                return "unknow";
            }
        }
    }
}

